
<!--[if lte IE 8.0]>
<script type="text/javascript" src="<?php echo $this->baseUrl() ?>/public/js/fix-zindex.js"></script>
<![endif]-->
<script type="text/javascript" src="<?php echo $this->baseUrl() ?>/public/js/jquery.md5.js"></script>

<div class="shoptop"><?php echo $this->translate( 'your_basket' ) ?></div>
<div class="box boxbasket">
	
	<div class="prodpage">
		<div class="acenter">
			<a href="javascript:void(null)" class="button prodmenu"><?php echo $this->translate( 'basket_contents' ) ?></a>
			<a href="javascript:void(null)" class="button prodmenu <?php echo ( !$this->nextStep ) ? ' buttonactive' : '' ?>"><?php echo $this->translate( 'basket_delivery' ) ?></a>
			<a href="javascript:void(null)" class="button prodmenu <?php echo ( $this->nextStep ) ? ' buttonactive' : '' ?>"><?php echo $this->translate( 'basket_payment' ) ?></a>
			<a href="javascript:void(null)" class="button prodmenu"><?php echo $this->translate( 'basket_confirmation' ) ?></a>
		</div>
	</div>
	
	
	<?php if( $this->userData || $this->fast ) { ?>
	<!-- start bar -->
	<div class="basketbar">
	
		<div class="sekction sekpos1">
			<p class="price"><?php 

		if( $this->fac_ok > 0 ) {
			$this->basket->sumDb();
		} else {
			$this->basket->sumDb( true );
		}
		echo $this->basket->sum;

		?></p>
			<p class="name"><?php echo $this->translate( 'brutto_value' ) ?></p>
		</div>
		
		<div class="plus">+</div>
		
		<div class="sekction sekpos2">
			<p class="price"><?php echo $this->basket->delivery ?></p>
			<p class="name"><?php echo $this->translate( 'value_of_shipment' ) ?></p>
		</div>
		
		<div class="equals">=</div>
		
		<div class="sekction sekpos3">
			<p class="price"><?php 
			echo number_format( $this->basket->sumInt + $this->basket->deliveryInt, 2, '.', ' ' );
			echo ' ' . $this->basket->curr;
		?></p>
			<p class="name"><?php echo $this->translate( 'payment_all' ); ?></p>
		</div>
		<?php if( $this->nextStep ) { ?>
		<a onclick="$('#facture-form').submit();" href="javascript:void(null)" class="buttonred" style="position:absolute; right:10px; top:27px"><?php echo $this->translate( 'checkout' ); ?></a>
		<?php } else { ?>
		<a onclick="$('#dispatch-form').submit();" href="javascript:void(null)" class="buttonred" style="position:absolute; right:10px; top:27px"><?php echo $this->translate( 'checkout' ); ?></a>
		<?php } ?>
	</div>
	<!-- end bar -->
	
	<div class="options">
		<?php if( $this->nextStep ) { ?>
		<a href="{baseUrl}/shop/delivery/f/<?php echo $this->fast; ?>" class="button"><?php echo $this->translate( 'back' ); ?></a>
		<?php } else { ?>
		<a href="{baseUrl}/shop/basket" class="button"><?php echo $this->translate( 'back' ); ?></a>
		<?php } ?>
		
		<?php 
	 
	// musi byc przynajmniej jeden profukt normalny 
	// aby byla mozliwosc odbioru osobistego

        	if( $this->nextStep ) 
        	{
         		echo '<a href="javascript:void(null)" onclick="cpyinfo()" class="button button2">' . $this->translate( 'copy_info' ) . '</a>';
        	} 
        	else 
        	{
        	    
    	    	if($this->basket->isAnySpecialProduct==false)
                {
        	    
        		 echo $this->inlineScript()->setScript('$(document).ready(function(){
        			var fac = $("#fac_ok");
        
        			$("#facilitystylish1").change(function(){
        				fac.val( $(this).val() );
        			});
        
        		 	$("#fac_back").click(function(){
        		 		fac.val( 0 );
        		 		$("#facility_box").css({ display: "none", opacity: 0 }).animate({
        						opacity: 1
        					}, 500, null, function(){
        						$(this).css({display:"none"});
        						$("#facility_link").css({display : "block"}).animate({
        							opacity: 1
        						});
        				});
        			});	
        
        			$("#facility_link").click( function(){
        				$(this).css({display: "block"}).animate({
        					opacity: 0
        				}, 800, null, function(){
        				
        					$(this).css({ display: "none" });
        					
        					$("#facility_box").css({
        						opacity: 0,
        						display: "block"
        					}).animate({
        						opacity: 1
        					})
        					
        					fac.val( $("#facilitystylish1").val() );
        				});
        			
        			} );
        		
        		});');
        
        		if( $this->fac_ok > 0 ) 
        		{
        		    /*
        			echo '<a href="javascript:void(null)" id="facility_link" style="display:none" class="cyellow">' . $this->translate( 'personal_collection' ) . '</a>';
        			echo '<div id="facility_box" class="boxstylish2" style="display:block;float:right;margin:0px;position:relative;"> <div id="fac_back" style="cursor:pointer;left:-47px;top:5px;position:absolute;"><b>&laquo;</b> cofnij</div>';
        			echo $this->formSelect( 'facility', $this->fac_ok, array('class' => 'stylish', 'id'=>'facilitystylish1'), $this->facilityList );
        			echo '</div>';
        			*/
        		    
        			echo '<a href="javascript:void(null)" id="facility_link" style="display:none;" class="button button2">' . $this->translate( 'personal_collection' ) . '</a>';
        			echo '<div id="facility_box" class="boxstylish2 aleft" style="display:block">';
        			echo '<div style="float:right; width:200px">';
        			echo $this->formSelect( 'facility', $this->fac_ok, array('class' => 'stylish', 'id'=>'facilitystylish1'), $this->facilityList );
        			echo '</div>';
        			echo '<div id="fac_back" style="cursor:pointer; float:right; height:23px; line-height:20px; width:50px; "><b>&laquo;</b> cofnij</div>';
        			echo '</div>';
        		} 
        		else 
        		{
        			echo '<a href="javascript:void(null)" id="facility_link" class="button button2">' . $this->translate( 'personal_collection' ) . '</a>';
        			echo '<div id="facility_box" class="boxstylish2 aleft" style="display:none">';
        			echo '<div style="float:right; width:200px">';
        			echo $this->formSelect( 'facility', false, array('class' => 'stylish', 'id'=>'facilitystylish1'), $this->facilityList );
        			echo '</div>';
        			echo '<div id="fac_back" style="cursor:pointer; float:right; height:23px; line-height:20px; width:50px; "><b>&laquo;</b> cofnij</div>';
        			echo '</div>';
        		}
        	}
	    }
	
	?>
		<div class="clr"></div>
	</div>
	<!-- end options -->
	
	<script type="text/javascript">
	<?php 
	if( $this->sess ) {
		foreach( $this->sess as $key => $value ) {
			echo 'var fv_' . $key .' = "' . $value . '";';		
		} 
	}
	?>
	</script>
	<?php if( $this->nextStep ) { ?>
		<?php echo $this->inlineScript()->setScript('
			var cpyinfo;
			$(document).ready(function(){	
			
			
	$.validator.addMethod("nameRegex", 
		function(value, element) {
        	return this.optional(element) || /^[^0-9]{2,}$/i.test(value);
    }, 
    "Możesz używać tylko liter.");			
    
				cpyinfo = function(){

					var fform = $("#facture-form").find( "input,select" );
					for( var i = 0, len = fform.length; i < len; i++ ) {
						try{
							if( eval( $( fform[i] ).attr( "name" ) ) ) {
								if( $( fform[i] ).attr( "name" ) == "fv_province" ) {
									var op = $( fform[i] ).find( "option" );
									for( var o = 0, len = op.length; o < len; o++ ) {
										if( o == eval( $( fform[i] ).attr( "name" ) ) ) {
											$( op[o] ).attr({ selected : "selected" });
											var txt = $( $( $("#fv_province_cn").find("li")[o] ).find("a") ).text();
											$(  $("#fv_province_cn").find( ".selectedTxt" ) ).empty().text( txt );
										}
									}
								} else if( $( fform[i] ).attr( "name" ) == "fv_country" ) {
									var op = $( fform[i] ).find( "option" );
									for( var e = 0, len = op.length; e < len; e++ ) {
					
										if( $( op[e] ).val() == eval( $( fform[i] ).attr( "name" ) ) ) {
											$( op[e] ).attr({ selected : "selected" });
											var txt = $( $( $("#fv_country_cn").find("li")[e] ).find("a") ).text();
											
											$(  $("#fv_country_cn").find( ".selectedTxt" ) ).empty().text( txt );

											if( $( op[e] ).val() != "PL" ) {
												$( "#fv_province_cn" ).animate({ opacity: 0 });
											}
										}
									}
								} else {
									$( fform[i] ).val( eval( $( fform[i] ).attr( "name" ) ) );
								}	
							}
						}catch(e){}
					}
				};
				$( "#fvcountrystyluis" ).change(function(){
				
					console.log( $(this).val() );
					if( $(this).val() != "PL" ) {
						$( "#fv_province_cn" ).animate({ opacity: 0 });
					} else {
						$( "#fv_province_cn" ).animate({ opacity: 1 });
					}
				});
				
				$.validator.addMethod("nameRegex", 
					function(value, element) {
			        	return this.optional(element) || /^[^0-9]+$/i.test(value);
			    }, 
					"Możesz używać tylko liter.");
			
				$("#facture-form").validate({
					rules: {
						fv_locality : {
							required: true,
							minlength: 5,
							nameRegex: true
						},
						fv_street : {
							required: true,
							minlength: 2
						},
						fv_nr_home : {
							required: true,
							minlength: 1
						},
						payment : {
							required: true
						},
						fv_name : {
							required: true,
							nameRegex: true
						},
						fv_surname : {
							required: true,
							nameRegex: true
						},
						fv_zip : {
							required: true,
							minlength: 5
						}
					},
					messages: {
						fv_name : "'. $this->translate( 'error_name' ) .'",
						fv_surname : "'. $this->translate( 'error_surname' ) .'",
						fv_locality : "'. $this->translate( 'error_locality' ) .'",
						fv_street : "'. $this->translate( 'error_street' ) .'",
						payment : "'. $this->translate( 'error_payment' ) .'",
						fv_nr_home : "'. $this->translate( 'error_nr_home' ) .'",
						fv_zip : "'. $this->translate( 'error_zip' ) .'"
					}
				});
			});
		') ?>
	<h2><?php echo $this->translate( 'facture_info' ) ?></h2>
	
		<form  action="{baseUrl}/shop/checkout" id="facture-form" method="post">
    	<table class="tab">
    		<tr>
    			<td class="aright"><?php echo $this->translate( 'nip' ) ?>:</td>
    			<td>
    				<input type="text" id="cfv_nip" name="fv_nip" value="<?php echo $this->fv_nip ?>">
    				<label class="error" style="display:none"><?php echo $this->translate( 'error_company' ) ?></label>
    			</td>
    		</tr>
    		<tr>
    			<td class="aright"><?php echo $this->translate( 'company_name' ) ?>:</td>
    			<td><input type="text" id="cfv_company_name" name="fv_company_name" value="<?php echo $this->fv_company_name ?>"></td>
    		</tr>
    		<tr>
    			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'name' ) ?>:</td>
    			<td><input type="text" id="cfv_name" name="fv_name" value="<?php echo $this->fv_name ?>"></td>
    		</tr>
    		<tr>
    			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'surname' ) ?>:</td>
    			<td><input type="text" id="cfv_surname" name="fv_surname" value="<?php echo $this->fv_surname ?>"></td>
    		</tr>
    		<tr>
    			<td class="aright"><?php echo $this->translate( 'province' ); ?>:</td>
    			<td>
    			<?php echo $this->formSelect( 'fv_province', $this->fv_province, array(
						'id'=>'fvprovincecnstylish'
					), Core_Static::$province ) ?>
    			</td>
    		</tr>
    		<tr>
    			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'country' ); ?>:</td>
    			<td>
    			<?php echo $this->formSelect( 'fv_country', ( $this->fv_country ) ? $this->fv_country : 'PL', array(
						'id'=>'fvcountrystyluis'
					), Core_Static::$country ) ?>
					<?php echo $this->inlineScript()->setScript( '
				
					$( "#country" ).change(function(){
						if( $(this).val() != "PL" ) {
							$( "#province_cn" ).animate({ opacity: 0 });
						} else {
							$( "#province_cn" ).animate({ opacity: 1 });
						}
		
					});
				' ); ?>
    			</td>
    		</tr>
    		<tr>
    			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'locality' ) ?>:</td>
    			<td><input type="text" id="cfv_locality" name="fv_locality" value="<?php echo $this->fv_locality ?>" ></td>
    		</tr>
    		<tr>
    			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'street' ) ?></td>
    			<td><input type="text" id="cfv_street" name="fv_street" value="<?php echo $this->fv_street ?>"></td>
    		</tr>
    		<tr>
    			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'nr_home' ) ?>:</td>
    			<td><input type="text" id="cfv_nr_home" name="fv_nr_home" value="<?php echo $this->fv_nr_home ?>"></td>
    		</tr>
    		<tr>
    			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'zip' ) ?>:</td>
    			<td><input type="text" id="cfv_zip" name="fv_zip" value="<?php echo $this->fv_zip ?>"></td>
    		</tr>
    	</table>
    	</form>
	
	<?php if( $sdv2 > 0 ) { ?>
	<h2>Sposób płatności</h2>
	<table class="paymethod">
		<?php if($this->pobranie): ?>
		<tr>
			<td><input type="radio" name="payment"  id="p1" value="p1"><label for="p1"></label> ZA POBRANIEM</td>
			<td>za przesyłke zapłacisz przy odbiorze.</td>
		</tr>
		<?php endif; ?>
		<tr>
			<td><input type="radio" name="payment" id="p2" value="p2"><label for="p2"></label> KARTA KREDYTOWA</td>
			<td>kartą kredytową w serwisie płatności.pl</td>
	
		</tr>
		<tr>
			<td><input type="radio" name="payment" id="p3" value="p3"><label for="p3"></label> PRZELEW ONLINE</td>
			<td>przelew online w serwisie płatności.pl.</td>
		</tr>
		<?php if($this->pobranie): ?>
		<tr>
			<td><input type="radio" name="payment" id="p4" value="p4"><label for="p4"></label> WPŁATA NA KONTO</td>
			<td>przedpłata na nasze konto bankowe (w tytule podaj numer zamówienia).</td>
		</tr>
		<?php endif; ?>
		<tr>
	
			<td><input type="radio" name="payment" id="p5" value="p5"><label for="p5"></label> PAYPAL</td>
			<td>płatność za pomocą serwisu paypal.pl</td>
		</tr>
	</table>
	
	<?php } ?>
	
	<div class="end"></div>
	
	
	<?php } else { ?>
	<?php echo $this->inlineScript()->setScript('
			$(document).ready(function(){	
    
			$.validator.addMethod("nameRegex", 
				function(value, element) {
		        	return this.optional(element) || /^[^0-9]+$/i.test(value);
		    }, 
				"Możesz używać tylko liter.");
				
			$.validator.addMethod("telRegex", 
				function(value, element) {
		        	return this.optional(element) || /^[0-9\-\ \(\)\+]+$/i.test(value);
		    }, 
		    "' . $this->translate( 'error_phone' ) . '");

				$("#dispatch-form").validate({
					rules: {
						email : {
							required: true,
							email: true
						},
						name : {
							required: true,
							minlength: 2,
							nameRegex: true
						},
						surname : {
							required: true,
							minlength: 2,
							nameRegex: true
						},
						phone : {
							required: true,
							telRegex: true,
							minlength:7
						},
						locality : {
							required: true,
							minlength: 5,
							nameRegex: true
						},
						street : {
							required: true,
							minlength: 2
						},
						nr_home : {
							required: true,
							minlength: 1
						},
						zip : {
							required: true,
							minlength: 5
						}
					},
					messages: {
						email : "' . $this->translate( 'error_email' ) . '",
						name : "' . $this->translate( 'error_name' ) . '",
						surname : "'. $this->translate( 'error_surname' ) .'",
						phone : "'. $this->translate( 'error_phone' ) .'",
						locality : "'. $this->translate( 'error_locality' ) .'",
						street : "'. $this->translate( 'error_street' ) .'",
						nr_home : "'. $this->translate( 'error_nr_home' ) .'",
						zip : "'. $this->translate( 'error_zip' ) .'"
					}
				});

				if( "'.$this->country.'" != "PL" && "'.$this->country.'" != "" ) {
					$( "#province_cn" ).animate({ opacity: 0 });
				};
				
				$("#countrystylish").change(function(){
		
					if( $(this).val() != "PL" ) {
						$("#province_cn").animate({ opacity: 0 });
					} else {
						$("#province_cn").animate({ opacity: 1 });
					}
				
				});
			});
		') ?>
	
	<h2><?php echo $this->translate( 'dispatch_info' ) ?></h2>
	
	<form id="dispatch-form" method="post" >
			<input type="hidden" id="fac_ok" name="fac_ok" value="<?php echo $this->fac_ok ?>" />
	<table class="tab">
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'email' ) ?>:</td>
			<td><input type="text" id="cemail" name="email" value="<?php echo $this->email ?>"></td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'name' ) ?>:</td>
			<td><input type="text" id="cname" name="name" value="<?php echo $this->name ?>"></td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'surname' ) ?>:</td>
			<td><input type="text" id="csurname" name="surname" value="<?php echo $this->surname ?>"></td>
		</tr>
		<tr>
			<td class="aright"><?php echo $this->translate( 'phone' ) ?>:</td>
			<td><input type="text" id="cphone" name="phone" value="<?php echo $this->phone ?>"></td>
		</tr>
		<tr>
			<td class="aright"><?php echo $this->translate( 'province' ); ?>:</td>
			<td>
					<?php echo $this->formSelect( 'province', $this->province, array(
						'id'=>'stylishprovince'
					), Core_Static::$province ) ?>
			</td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'country' ); ?>:</td>
			<td>
			<?php echo $this->formSelect( 'country', ( $this->country ) ? $this->country : 'PL', array(
						'id'=>'countrystylish'
					), Core_Static::$country ) ?>
					<?php echo $this->inlineScript()->setScript( '
					$( "#country" ).change(function(){
						console.log( $(this).val() );
						
						if( $(this).val() != "PL" ) {
							$( "#province_cn" ).animate({ opacity: 0 });
						} else {
							$( "#province_cn" ).animate({ opacity: 1 });
						}
		
					});
				' ); ?>
			</td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'locality' ) ?>y:</td>
			<td><input type="text" id="clocality" name="locality" value="<?php echo $this->locality ?>"></td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'street' ) ?></td>
			<td><input type="text" id="cstreet" name="street" value="<?php echo $this->street ?>"></td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'nr_home' ) ?>:</td>
			<td><input type="text" id="cnr_home" name="nr_home" value="<?php echo $this->nr_home ?>"></td>
		</tr>
		<tr>
			<td class="aright"><span class="star">*</span><?php echo $this->translate( 'zip' ) ?>:</td>
			<td><input type="text" id="czip" name="zip" value="<?php echo $this->zip ?>"></td>
		</tr>
		
	</table>
	</form>
	<div class="end"></div>
	<?php } ?>

	<?php } else { ?>
	
	<?php echo $this->inlineScript()->setScript('
	$(document).ready(function(){
		$.validator.setDefaults({
			submitHandler: function(e) { 
				var fields = $(e).find( "input.style1" );
				
				$("#log-form-box").animate({
					opacity: 0
				});
				
				$.post(
					baseUrl + "/index/login",
					{
						login : $( "#cemail" ).val(),
						password : $.md5( $( "#cpass" ).val() ),
						json : true
					},
					function( resp ){
						if( resp.status ) {
							window.location.reload();
						} else {
							alert( "' . $this->translate( 'error_login' ) . '" );
							$("#log-form-box").animate({
								opacity: 1
							});
						}
					},
					"json"
				);
			}
		});
	
		$("#login-form").validate({
			rules: {
				email : {
					required: true,
					email: true
				},
				pass : {
					required: true,
					minlength: 2
				}
			},
			messages: {
				email : "' . $this->translate( 'error_email' ) . '",
				pass : "'. $this->translate( 'error_password' ) .'"
			}
		});
	});
	') ?>
	<div id="log-form-box">
	<h2><?php echo $this->translate( 'dispatch_info' ) ?></h2>
	
	<form id="login-form" onsubmit="return false" method="post" action="">
	<table class="tab">
		<tr>
			<td class="aright"><?php echo $this->translate( 'basket_login' ); ?>:</td>
			<td><input type="text" id="cemail" name="email"></td>
		</tr>
		<tr>
			<td class="aright"><?php echo $this->translate( 'basket_pass' ); ?>:</td>
			<td><input type="password" id="cpass" name="pass"></td>
		</tr>
	</table>
	</form>
	
	<div class="line" style="margin:10px 0"></div>
	
	<div class="acenter">
	<a href="javascript:;" class="button" onclick="$('#login-form').submit()"><?php echo $this->translate( 'basket_loged' ) ?></a>
	</div>
	
	<div class="acenter" style="margin-top:20px">
	<p>
		<a href="{baseUrl}/index/newaccount" class="orange">załóż konto</a> <span style="margin:0 10px">/</span> 
		<a href="{baseUrl}/index/remindpass"><?php echo $this->translate( 'basket_remind' ) ?></a></p>
	</div>

	
	
	<div class="end"></div>
	</div>
	<?php }?>
</div>
<!-- end box -->



<!--
[if lte IE 8.0]>
<script type="text/javascript" src="<?php echo $this->baseUrl() ?>/public/js/fix-zindex.js"></script>
<![endif]
<script type="text/javascript" src="<?php echo $this->baseUrl() ?>/public/js/jquery.md5.js"></script>

<h2 class="bold"><?php echo $this->translate( 'your_basket' ) ?></h2>

<div class="content">
	<table class="stoproc mtop10 basketmenu">
		<tr>
			<td class="acenter gradyellow" style="width:160px"><a href="javascript:void(null)" class="type1"><?php echo $this->translate( 'basket_contents' ) ?></a></td>
			<td class="acenter gradyellow" style="width:160px"><a href="javascript:void(null)" class="type1<?php echo ( !$this->nextStep ) ? ' focus' : '' ?>"><?php echo $this->translate( 'basket_delivery' ) ?></a></td>
			<td class="acenter gradyellow" style="width:160px"><a href="javascript:void(null)" class="type1<?php echo ( $this->nextStep ) ? ' focus' : '' ?>"><?php echo $this->translate( 'basket_payment' ) ?></a></td>
			<td class="acenter gradyellow" style="width:160px"><a href="javascript:void(null)" class="type1"><?php echo $this->translate( 'basket_confirmation' ) ?></a></td>
		</tr>
	</table>
	
	<?php if( $this->userData || $this->fast ) { ?>
	
	
	<div class="basketbar">
	
		<div style="position:absolute; left:27px; top:18px">
		<p class="price"><?php 

		if( $this->fac_ok > 0 ) {
			$this->basket->sumDb();
		} else {
			$this->basket->sumDb( true );
		}
		echo $this->basket->sum;

		?></p><p class="name"><?php echo $this->translate( 'brutto_value' ) ?></p>
		</div>
		
		<div style="position:absolute; left:157px; top:30px">+</div>
			
		<div style="position:absolute; left:195px; top:18px">
		<p class="price"><?php echo $this->basket->delivery ?></p><p class="name"><?php echo $this->translate( 'value_of_shipment' ) ?></p>
		</div>
		
		<div style="position:absolute; left:343px; top:30px">=</div>
		
		<div style="position:absolute; left:380px; top:18px">
		<p class="price"><?php 
			echo number_format( $this->basket->sumInt + $this->basket->deliveryInt, 2, '.', ' ' );
			echo ' ' . $this->basket->curr;
		?></p><p class="name"><?php echo $this->translate( 'payment_all' ); ?></p>
		</div>
		<?php if( $this->nextStep ) { ?>
		<a onclick="$('#facture-form').submit();" href="javascript:void(null)" class="button4" style="position:absolute; right:10px; top:27px"><?php echo $this->translate( 'checkout' ); ?></a>
		<?php } else { ?>
		<a onclick="$('#dispatch-form').submit();" href="javascript:void(null)" class="button4" style="position:absolute; right:10px; top:27px"><?php echo $this->translate( 'checkout' ); ?></a>
		<?php } ?>
	</div>
	<?php 
	$sdv2 = 1;
	if(isSet($this->basket->sess->basket['value_vouchers'])) {?>
	<div class="basketbar">
		<div style="position:absolute; left:27px; top:31px">
			<p class="name"><?php echo $this->translate( 'delivery_voucher_value_do' ); ?>: </p>
		</div>
		<div style="position:absolute; left:375px; top:30px">
		<p class="price">
			<?php 
$sdv2 = $this->basket->sumInt + $this->basket->deliveryInt - $this->basket->sess->basket['value_vouchers'];
			    $sdv = number_format( $sdv2, 2, '.', ' ' );
			    if($sdv>0) echo $sdv; else echo number_format(0, 2, '.', ' ' );
			    echo $this->basket->curr;
		    ?>
		</p>
		</div>
	</div>
	<?php }?>
	<table class="stoproc" style="margin-top:10px; *margin-top:20px ">
	<tr>
	<td>
	<?php if( $this->nextStep ) { ?>
	<a href="<?php echo $this->baseUrl() ?>/shop/delivery/f/<?php echo $this->fast; ?>" class="button4"><?php echo $this->translate( 'back' ); ?></a>
	<?php } else { ?>
	<a href="<?php echo $this->baseUrl() ?>/shop/basket" class="button4"><?php echo $this->translate( 'back' ); ?></a>
	<?php } ?>
	</td>
	<td class="aright">
	<?php 
	 
	// musi byc przynajmniej jeden profukt normalny 
	// aby byla mozliwosc odbioru osobistego

        	if( $this->nextStep ) 
        	{
         		echo '<a href="javascript:void(null)" onclick="cpyinfo()" class="cyellow">' . $this->translate( 'copy_info' ) . '</a>';
        	} 
        	else 
        	{
        	    
    	    	if($this->basket->isAnySpecialProduct==false)
                {
        	    
        		 echo $this->inlineScript()->setScript('$(document).ready(function(){
        			var fac = $("#fac_ok");
        
        			$("#facilitystylish1").change(function(){
        				fac.val( $(this).val() );
        			});
        
        		 	$("#fac_back").click(function(){
        		 		fac.val( 0 );
        		 		$("#facility_box").css({ display: "none", opacity: 0 }).animate({
        						opacity: 1
        					}, 500, null, function(){
        						$(this).css({display:"none"});
        						$("#facility_link").css({display : "block"}).animate({
        							opacity: 1
        						});
        				});
        			});	
        
        			$("#facility_link").click( function(){
        				$(this).css({display: "block"}).animate({
        					opacity: 0
        				}, 800, null, function(){
        				
        					$(this).css({ display: "none" });
        					
        					$("#facility_box").css({
        						opacity: 0,
        						display: "block"
        					}).animate({
        						opacity: 1
        					})
        					
        					fac.val( $("#facilitystylish1").val() );
        				});
        			
        			} );
        		
        		});');
        
        		if( $this->fac_ok > 0 ) 
        		{
        		    /*
        			echo '<a href="javascript:void(null)" id="facility_link" style="display:none" class="cyellow">' . $this->translate( 'personal_collection' ) . '</a>';
        			echo '<div id="facility_box" class="boxstylish2" style="display:block;float:right;margin:0px;position:relative;"> <div id="fac_back" style="cursor:pointer;left:-47px;top:5px;position:absolute;"><b>&laquo;</b> cofnij</div>';
        			echo $this->formSelect( 'facility', $this->fac_ok, array('class' => 'stylish', 'id'=>'facilitystylish1'), $this->facilityList );
        			echo '</div>';
        			*/
        		    
        			echo '<a href="javascript:void(null)" id="facility_link" style="display:none;" class="cyellow">' . $this->translate( 'personal_collection' ) . '</a>';
        			echo '<div id="facility_box" class="boxstylish2 aleft" style="display:block">';
        			echo '<div style="float:right; width:200px">';
        			echo $this->formSelect( 'facility', $this->fac_ok, array('class' => 'stylish', 'id'=>'facilitystylish1'), $this->facilityList );
        			echo '</div>';
        			echo '<div id="fac_back" style="cursor:pointer; float:right; height:23px; line-height:20px; width:50px; "><b>&laquo;</b> cofnij</div>';
        			echo '</div>';
        		} 
        		else 
        		{
        			echo '<a href="javascript:void(null)" id="facility_link" class="cyellow">' . $this->translate( 'personal_collection' ) . '</a>';
        			echo '<div id="facility_box" class="boxstylish2 aleft" style="display:none">';
        			echo '<div style="float:right; width:200px">';
        			echo $this->formSelect( 'facility', false, array('class' => 'stylish', 'id'=>'facilitystylish1'), $this->facilityList );
        			echo '</div>';
        			echo '<div id="fac_back" style="cursor:pointer; float:right; height:23px; line-height:20px; width:50px; "><b>&laquo;</b> cofnij</div>';
        			echo '</div>';
        		}
        	}
	    }
	
	?></td>
	</tr>
	</table>
	<script type="text/javascript">
	<?php 
	if( $this->sess ) {
		foreach( $this->sess as $key => $value ) {
			echo 'var fv_' . $key .' = "' . $value . '";';		
		} 
	}
	?>
	</script>

	<?php if( $this->nextStep ) { ?>
		<?php echo $this->inlineScript()->setScript('
			var cpyinfo;
			$(document).ready(function(){	
			
			
	$.validator.addMethod("nameRegex", 
		function(value, element) {
        	return this.optional(element) || /^[^0-9]{2,}$/i.test(value);
    }, 
    "Możesz używać tylko liter.");			
    
				cpyinfo = function(){

					var fform = $("#facture-form").find( "input,select" );
					for( var i = 0, len = fform.length; i < len; i++ ) {
						try{
							if( eval( $( fform[i] ).attr( "name" ) ) ) {
								if( $( fform[i] ).attr( "name" ) == "fv_province" ) {
									var op = $( fform[i] ).find( "option" );
									for( var o = 0, len = op.length; o < len; o++ ) {
										if( o == eval( $( fform[i] ).attr( "name" ) ) ) {
											$( op[o] ).attr({ selected : "selected" });
											var txt = $( $( $("#fv_province_cn").find("li")[o] ).find("a") ).text();
											$(  $("#fv_province_cn").find( ".selectedTxt" ) ).empty().text( txt );
										}
									}
								} else if( $( fform[i] ).attr( "name" ) == "fv_country" ) {
									var op = $( fform[i] ).find( "option" );
									for( var e = 0, len = op.length; e < len; e++ ) {
					
										if( $( op[e] ).val() == eval( $( fform[i] ).attr( "name" ) ) ) {
											$( op[e] ).attr({ selected : "selected" });
											var txt = $( $( $("#fv_country_cn").find("li")[e] ).find("a") ).text();
											
											$(  $("#fv_country_cn").find( ".selectedTxt" ) ).empty().text( txt );

											if( $( op[e] ).val() != "PL" ) {
												$( "#fv_province_cn" ).animate({ opacity: 0 });
											}
										}
									}
								} else {
									$( fform[i] ).val( eval( $( fform[i] ).attr( "name" ) ) );
								}	
							}
						}catch(e){}
					}
				};
				$( "#fvcountrystyluis" ).change(function(){
				
					console.log( $(this).val() );
					if( $(this).val() != "PL" ) {
						$( "#fv_province_cn" ).animate({ opacity: 0 });
					} else {
						$( "#fv_province_cn" ).animate({ opacity: 1 });
					}
				});
				
				$.validator.addMethod("nameRegex", 
					function(value, element) {
			        	return this.optional(element) || /^[^0-9]+$/i.test(value);
			    }, 
					"Możesz używać tylko liter.");
			
				$("#facture-form").validate({
					rules: {
						fv_locality : {
							required: true,
							minlength: 5,
							nameRegex: true
						},
						fv_street : {
							required: true,
							minlength: 2
						},
						fv_nr_home : {
							required: true,
							minlength: 1
						},
						payment : {
							required: true
						},
						fv_name : {
							required: true,
							nameRegex: true
						},
						fv_surname : {
							required: true,
							nameRegex: true
						},
						fv_zip : {
							required: true,
							minlength: 5
						}
					},
					messages: {
						fv_name : "'. $this->translate( 'error_name' ) .'",
						fv_surname : "'. $this->translate( 'error_surname' ) .'",
						fv_locality : "'. $this->translate( 'error_locality' ) .'",
						fv_street : "'. $this->translate( 'error_street' ) .'",
						payment : "'. $this->translate( 'error_payment' ) .'",
						fv_nr_home : "'. $this->translate( 'error_nr_home' ) .'",
						fv_zip : "'. $this->translate( 'error_zip' ) .'"
					}
				});
			});
		') ?>
	
		<h3><?php echo $this->translate( 'facture_info' ) ?></h3>
		
		<form action="<?php echo $this->baseUrl() ?>/shop/checkout" id="facture-form" method="post">
			<table class="mcenter">
			<tr>
				<td>
				<?php echo $this->translate( 'nip' ) ?>
				</td>
				<td class="mancheck">
				<input type="text" id="cfv_nip" name="fv_nip" value="<?php echo $this->fv_nip ?>" class="style1 width410">
				<label class="error" style="display:none"><?php echo $this->translate( 'error_company' ) ?></label>
				</td>
			</tr>
			<tr>
				<td>
				<?php echo $this->translate( 'company_name' ) ?>
				</td>
				<td class="mancheck">
				<input type="text" id="cfv_company_name" name="fv_company_name" value="<?php echo $this->fv_company_name ?>" class="style1 width410">
				
				</td>
			</tr>
			<tr>
				<td>
				<?php echo $this->translate( 'name' ) ?><span class="gw">*</span>
				</td>
				<td class="mancheck">
				<input type="text" id="cfv_name" name="fv_name" value="<?php echo $this->fv_name ?>" class="style1 width410">
				
				</td>
			</tr>
			<tr>
				<td>
				<?php echo $this->translate( 'surname' ) ?><span class="gw">*</span>
				</td>
				<td class="mancheck">
				<input type="text" id="cfv_surname" name="fv_surname" value="<?php echo $this->fv_surname ?>" class="style1 width410">
				
				</td>
			</tr>
			<tr>
				<td class="paddingr12">
				<?php echo $this->translate( 'province' ); ?>
				<span class="gw">*</span>
				</td>
				<td>
				<div id="fv_province_cn" class="boxstylish2">
					<?php echo $this->formSelect( 'fv_province', $this->fv_province, array(
						'class' => 'stylish', 'id'=>'fvprovincecnstylish'
					), Core_Static::$province ) ?>
				</div>
				</td>
			</tr>
			<tr>
				<td class="paddingr12">
				<?php echo $this->translate( 'country' ); ?><span class="gw">*</span>
				</td>
				<td>
				<div id="fv_country_cn" class="boxstylish2">
					<?php echo $this->formSelect( 'fv_country', ( $this->fv_country ) ? $this->fv_country : 'PL', array(
						'class' => 'stylish', 'id'=>'fvcountrystyluis'
					), Core_Static::$country ) ?>
				</div>
				<?php echo $this->inlineScript()->setScript( '
				
					$( "#country" ).change(function(){
						if( $(this).val() != "PL" ) {
							$( "#province_cn" ).animate({ opacity: 0 });
						} else {
							$( "#province_cn" ).animate({ opacity: 1 });
						}
		
					});
				' ); ?>
				</td>
			</tr>
			<tr>
				<td>
				<?php echo $this->translate( 'locality' ) ?><span class="gw">*</span>
				</td>
				<td>
				<input type="text" id="cfv_locality" name="fv_locality" value="<?php echo $this->fv_locality ?>" class="style1 width410">
				</td>
			</tr>
			<tr>
				<td>
				<?php echo $this->translate( 'street' ) ?><span class="gw">*</span>
				</td>
				<td>
				<input type="text" id="cfv_street" name="fv_street" value="<?php echo $this->fv_street ?>" class="style1 width410">
				</td>
			</tr>
			<tr>
				<td>
				<?php echo $this->translate( 'nr_home' ) ?><span class="gw">*</span>
				</td>
				<td>
				<input type="text" id="cfv_nr_home" name="fv_nr_home" value="<?php echo $this->fv_nr_home ?>" class="style1 width250">
				</td>
			</tr>
			<tr>
				<td>
				<?php echo $this->translate( 'zip' ) ?><span class="gw">*</span>
				</td>
				<td>
				<input type="text" id="cfv_zip" name="fv_zip" value="<?php echo $this->fv_zip ?>" class="style1 width250">
				</td>
			</tr>
			</table>
		
	<?php if( $sdv2 > 0 ) { ?>
	<h3>SPOSÓB PŁATNOŚCI</h3>
	<table class="stoproc">

	<?php if($this->pobranie): ?>
	<tr>
		<td><input type="radio" name="payment"  id="p1" value="p1"><label for="p1"></label> ZA POBRANIEM</td>
		<td>za przesyłke zapłacisz przy odbiorze.</td>
	</tr>
	<?php endif; ?>
	<tr>
		<td><input type="radio" name="payment" id="p2" value="p2"><label for="p2"></label> KARTA KREDYTOWA</td>
		<td>kartą kredytową w serwisie płatności.pl</td>

	</tr>
	<tr>
		<td><input type="radio" name="payment" id="p3" value="p3"><label for="p3"></label> PRZELEW ONLINE</td>
		<td>przelew online w serwisie płatności.pl.</td>
	</tr>
	<?php if($this->pobranie): ?>
	<tr>
		<td><input type="radio" name="payment" id="p4" value="p4"><label for="p4"></label> WPŁATA NA KONTO</td>
		<td>przedpłata na nasze konto bankowe (w tytule podaj numer zamówienia).</td>
	</tr>
	<?php endif; ?>
	<tr>

		<td><input type="radio" name="payment" id="p5" value="p5"><label for="p5"></label> PAYPAL</td>
		<td>płatność za pomocą serwisu paypal.pl</td>
	</tr>
	</table>
	<?php } ?>
		</form>
	
	<?php } else { ?>
	
		<?php echo $this->inlineScript()->setScript('
			$(document).ready(function(){	
    
			$.validator.addMethod("nameRegex", 
				function(value, element) {
		        	return this.optional(element) || /^[^0-9]+$/i.test(value);
		    }, 
				"Możesz używać tylko liter.");
				
			$.validator.addMethod("telRegex", 
				function(value, element) {
		        	return this.optional(element) || /^[0-9\-\ \(\)\+]+$/i.test(value);
		    }, 
		    "' . $this->translate( 'error_phone' ) . '");

				$("#dispatch-form").validate({
					rules: {
						email : {
							required: true,
							email: true
						},
						name : {
							required: true,
							minlength: 2,
							nameRegex: true
						},
						surname : {
							required: true,
							minlength: 2,
							nameRegex: true
						},
						phone : {
							required: true,
							telRegex: true,
							minlength:7
						},
						locality : {
							required: true,
							minlength: 5,
							nameRegex: true
						},
						street : {
							required: true,
							minlength: 2
						},
						nr_home : {
							required: true,
							minlength: 1
						},
						zip : {
							required: true,
							minlength: 5
						}
					},
					messages: {
						email : "' . $this->translate( 'error_email' ) . '",
						name : "' . $this->translate( 'error_name' ) . '",
						surname : "'. $this->translate( 'error_surname' ) .'",
						phone : "'. $this->translate( 'error_phone' ) .'",
						locality : "'. $this->translate( 'error_locality' ) .'",
						street : "'. $this->translate( 'error_street' ) .'",
						nr_home : "'. $this->translate( 'error_nr_home' ) .'",
						zip : "'. $this->translate( 'error_zip' ) .'"
					}
				});

				if( "'.$this->country.'" != "PL" && "'.$this->country.'" != "" ) {
					$( "#province_cn" ).animate({ opacity: 0 });
				};
				
				$("#countrystylish").change(function(){
		
					if( $(this).val() != "PL" ) {
						$("#province_cn").animate({ opacity: 0 });
					} else {
						$("#province_cn").animate({ opacity: 1 });
					}
				
				});
			});
		') ?>
		<h3><?php echo $this->translate( 'dispatch_info' ) ?></h3>
		
		<form id="dispatch-form" method="post">
			<input type="hidden" id="fac_ok" name="fac_ok" value="<?php echo $this->fac_ok ?>" />
			<table class="mcenter">
			<tr>
				<td>
				<?php echo $this->translate( 'email' ) ?><span class="gw">*</span>
				</td>
				<td>
				<input type="text" id="cemail" name="email" value="<?php echo $this->email ?>" class="style1 width410">
				</td>
			</tr>
			<tr>
				<td>
				<?php echo $this->translate( 'name' ) ?><span class="gw">*</span>
				</td>
				<td>
				<input type="text" id="cname" name="name" value="<?php echo $this->name ?>" class="style1 width410">
				</td>
			</tr>
			<tr>
				<td>
				<?php echo $this->translate( 'surname' ) ?><span class="gw">*</span>
				</td>
				<td>
				<input type="text" id="csurname" name="surname" value="<?php echo $this->surname ?>" class="style1 width410">
				</td>
			</tr>
			<tr>
				<td>
				<?php echo $this->translate( 'phone' ) ?><span class="gw">*</span>
				</td>
				<td>
				<input type="text" id="cphone" name="phone" value="<?php echo $this->phone ?>" class="style1 width410">
				</td>
			</tr>
			<tr>
				<td class="paddingr12">
				<?php echo $this->translate( 'province' ); ?>
				<span class="gw">*</span>
				</td>
				<td>
				<div id="province_cn" class="boxstylish2">
					<?php echo $this->formSelect( 'province', $this->province, array(
						'class' => 'stylish', 'id'=>'stylishprovince'
					), Core_Static::$province ) ?>
				</div>
				</td>
			</tr>
			<tr>
				<td class="paddingr12">
				<?php echo $this->translate( 'country' ); ?><span class="gw">*</span>
				</td>
				<td>
				<div class="boxstylish2">
					<?php echo $this->formSelect( 'country', ( $this->country ) ? $this->country : 'PL', array(
						'class' => 'stylish', 'id'=>'countrystylish'
					), Core_Static::$country ) ?>
				</div>
				<?php echo $this->inlineScript()->setScript( '
					$( "#country" ).change(function(){
						console.log( $(this).val() );
						
						if( $(this).val() != "PL" ) {
							$( "#province_cn" ).animate({ opacity: 0 });
						} else {
							$( "#province_cn" ).animate({ opacity: 1 });
						}
		
					});
				' ); ?>
				</td>
			</tr>
			<tr>
				<td>
				<?php echo $this->translate( 'locality' ) ?><span class="gw">*</span>
				</td>
				<td>
				<input type="text" id="clocality" name="locality" value="<?php echo $this->locality ?>" class="style1 width410">
				</td>
			</tr>
			<tr>
				<td>
				<?php echo $this->translate( 'street' ) ?><span class="gw">*</span>
				</td>
				<td>
				<input type="text" id="cstreet" name="street" value="<?php echo $this->street ?>" class="style1 width410">
				</td>
			</tr>
			<tr>
				<td>
				<?php echo $this->translate( 'nr_home' ) ?><span class="gw">*</span>
				</td>
				<td>
				<input type="text" id="cnr_home" name="nr_home" value="<?php echo $this->nr_home ?>" class="style1 width250">
				</td>
			</tr>
			<tr>
				<td>
				<?php echo $this->translate( 'zip' ) ?><span class="gw">*</span>
				</td>
				<td>
				<input type="text" id="czip" name="zip" value="<?php echo $this->zip ?>" class="style1 width250">
				</td>
			</tr>
			</table>
	</form>
		
	<?php } ?>

	<?php } else { ?>
	<?php echo $this->inlineScript()->setScript('
	$(document).ready(function(){
		$.validator.setDefaults({
			submitHandler: function(e) { 
				var fields = $(e).find( "input.style1" );
				
				$("#login-form").animate({
					opacity: 0
				});
				
				$.post(
					baseUrl + "/index/login",
					{
						login : $( fields[0] ).val(),
						password : $.md5( $( fields[1] ).val() ),
						json : true
					},
					function( resp ){
						if( resp.status ) {
							window.location.reload();
						} else {
							alert( "' . $this->translate( 'error_login' ) . '" );
							$("#login-form").animate({
								opacity: 1
							});
						}
					},
					"json"
				);
			}
		});
	
		$("#login-form").validate({
			rules: {
				email : {
					required: true,
					email: true
				},
				pass : {
					required: true,
					minlength: 2
				}
			},
			messages: {
				email : "' . $this->translate( 'error_email' ) . '",
				pass : "'. $this->translate( 'error_password' ) .'"
			}
		});
	});
	') ?>
	<div class="acenter">
		<form id="login-form" onsubmit="return false" method="post" action="">
		<p class="mtop20"><input type="text" id="cemail" name="email" class="style1 acenter" style="width:250px" value="<?php echo $this->translate( 'basket_login' ); ?>"  onfocus="if(this.value=='<?php echo $this->translate( 'basket_login' ); ?>')this.value=''" onblur="if(this.value=='')this.value='<?php echo $this->translate( 'basket_login' ); ?>'"></p>
		<p class="mtop10"><input type="password" id="cpass" name="pass" class="style1 acenter" style="width:250px" value="<?php echo $this->translate( 'basket_pass' ); ?>" onfocus="if(this.value=='<?php echo $this->translate( 'basket_pass' ); ?>')this.value=''" onblur="if(this.value=='')this.value='<?php echo $this->translate( 'basket_pass' ); ?>'"></p>
		<p class="mtop10"><input type="submit" class="button3" value="<?php echo $this->translate( 'basket_loged' ) ?>"></p>
		</form>
		
		<div  class="mtop10">
			<a href="<?php echo $this->baseUrl() ?>/shop/delivery/f/1" class="cyellow bold" style="margin:0 10px"><?php echo $this->translate( 'basket_quickshop' ) ?></a>
			<a href="<?php echo $this->baseUrl() ?>/index/newaccount" class="cyellow" style="margin:0 10px"><?php echo $this->translate( 'basket_newaccount' ) ?></a>
			<a href="<?php echo $this->baseUrl() ?>/index/remindpass" style="margin:0 10px"><?php echo $this->translate( 'basket_remind' ) ?></a>
		</div>
	</div>
	<?php } ?>
</div>-->